package com.atguigu.webapp.controller.payment;


import com.atguigu.common.result.Result;
import com.atguigu.model.pojo.PaymentType;
import com.atguigu.webapp.service.PaymentTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "支付方式接口")
@RestController
@RequestMapping("/app/payment")
public class PaymentTypeController {


    @Autowired
    private PaymentTypeService paymentTypeService;

    @Operation(summary = "根据房间id获取可选支付方式列表")
    @Parameters({
            @Parameter(name = "id",description = "房间id",in = ParameterIn.QUERY)
    })
    @GetMapping("listByRoomId")
    public Result<List<PaymentType>> selectListByRoomId(@RequestParam Long id) {
        List<PaymentType> typeList = paymentTypeService.selectListByRoomId(id);
        return Result.ok(typeList);
    }

    @Operation(summary = "获取全部支付方式列表")
    @GetMapping("list")
    public Result<List<PaymentType>> list() {
        List<PaymentType> typeList = paymentTypeService.list();
        return Result.ok(typeList);
    }
}
